\hypertarget{class_tcp_socket}{\section{Tcp\+Socket类 参考}
\label{class_tcp_socket}\index{Tcp\+Socket@{Tcp\+Socket}}
}


Tcp\+Socket类  




{\ttfamily \#include $<$Socket.\+h$>$}

类 Tcp\+Socket 继承关系图\+:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[height=3.000000cm]{class_tcp_socket}
\end{center}
\end{figure}
\subsection*{Public 成员函数}
\begin{DoxyCompactItemize}
\item 
sint32 \hyperlink{class_tcp_socket_a5e0e69092165d6847478a27006b8a8c6}{open} ()
\begin{DoxyCompactList}\small\item\em 打开\+T\+C\+P socket \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a58d2fff73fb69eb3f18b00aca7d6c87a}{close} ()
\begin{DoxyCompactList}\small\item\em 关闭\+T\+C\+P socket \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a35fb1c8b1f5235bce6418a75252c136e}{read\+Data} (char $\ast$buf, sint32 len, sint32 timeout\+Ms=-\/1)
\begin{DoxyCompactList}\small\item\em T\+C\+P socket接收数据 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a5f7504d2465e529139750cd36f794822}{write\+Data} (const char $\ast$buf, sint32 len, sint32 timeout\+Ms=-\/1)
\begin{DoxyCompactList}\small\item\em T\+C\+P socket发送数据 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a5aa820cc351f24dada219b243e832bc0}{listen\+Connection} (sint32 maxpend)
\begin{DoxyCompactList}\small\item\em T\+C\+P socket监听连接 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a126ef6e4d23288de68432af73ec46cb1}{accept\+Connection} (\hyperlink{class_tcp_socket}{Tcp\+Socket} \&new\+Socket)
\begin{DoxyCompactList}\small\item\em T\+C\+P socket接受连接 \end{DoxyCompactList}\item 
sint32 \hyperlink{class_tcp_socket_a5470902009a68d3fd66c924eb33a6737}{connect\+To\+Host} (uint16 peer\+Port, std\+::string peer\+Addr)
\begin{DoxyCompactList}\small\item\em T\+C\+P socket连接远端 \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{额外继承的成员函数}


\subsection{详细描述}
Tcp\+Socket类 

\subsection{成员函数说明}
\hypertarget{class_tcp_socket_a126ef6e4d23288de68432af73ec46cb1}{\index{Tcp\+Socket@{Tcp\+Socket}!accept\+Connection@{accept\+Connection}}
\index{accept\+Connection@{accept\+Connection}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{accept\+Connection}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::accept\+Connection (
\begin{DoxyParamCaption}
\item[{{\bf Tcp\+Socket} \&}]{newsocket}
\end{DoxyParamCaption}
)}}\label{class_tcp_socket_a126ef6e4d23288de68432af73ec46cb1}


T\+C\+P socket接受连接 


\begin{DoxyParams}{参数}
{\em newsocket} & 接受的新连接 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_tcp_socket_a58d2fff73fb69eb3f18b00aca7d6c87a}{\index{Tcp\+Socket@{Tcp\+Socket}!close@{close}}
\index{close@{close}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{close}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::close (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_tcp_socket_a58d2fff73fb69eb3f18b00aca7d6c87a}


关闭\+T\+C\+P socket 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


重载 \hyperlink{class_socket_a1fe4c90416cad39e96049019d178fb37}{Socket} .

\hypertarget{class_tcp_socket_a5470902009a68d3fd66c924eb33a6737}{\index{Tcp\+Socket@{Tcp\+Socket}!connect\+To\+Host@{connect\+To\+Host}}
\index{connect\+To\+Host@{connect\+To\+Host}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{connect\+To\+Host}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::connect\+To\+Host (
\begin{DoxyParamCaption}
\item[{uint16}]{port, }
\item[{std\+::string}]{ipaddr}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_tcp_socket_a5470902009a68d3fd66c924eb33a6737}


T\+C\+P socket连接远端 


\begin{DoxyParams}{参数}
{\em port} & 对端端口 \\
\hline
{\em ipaddr} & 对端\+I\+P地址 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回接收的数据长度,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


重载 \hyperlink{class_socket_abfbea049b117c0f4c91405b31b4694e4}{Socket} .

\hypertarget{class_tcp_socket_a5aa820cc351f24dada219b243e832bc0}{\index{Tcp\+Socket@{Tcp\+Socket}!listen\+Connection@{listen\+Connection}}
\index{listen\+Connection@{listen\+Connection}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{listen\+Connection}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::listen\+Connection (
\begin{DoxyParamCaption}
\item[{sint32}]{maxpending}
\end{DoxyParamCaption}
)}}\label{class_tcp_socket_a5aa820cc351f24dada219b243e832bc0}


T\+C\+P socket监听连接 


\begin{DoxyParams}{参数}
{\em maxpend} & 最大挂起连接数 \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}
\hypertarget{class_tcp_socket_a5e0e69092165d6847478a27006b8a8c6}{\index{Tcp\+Socket@{Tcp\+Socket}!open@{open}}
\index{open@{open}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{open}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::open (
\begin{DoxyParamCaption}
{}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_tcp_socket_a5e0e69092165d6847478a27006b8a8c6}


打开\+T\+C\+P socket 


\begin{DoxyParams}{参数}
{\em void} & \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回\+S\+T\+A\+T\+U\+S\+\_\+\+O\+K,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


实现了 \hyperlink{class_socket}{Socket}.

\hypertarget{class_tcp_socket_a35fb1c8b1f5235bce6418a75252c136e}{\index{Tcp\+Socket@{Tcp\+Socket}!read\+Data@{read\+Data}}
\index{read\+Data@{read\+Data}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{read\+Data}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::read\+Data (
\begin{DoxyParamCaption}
\item[{char $\ast$}]{buf, }
\item[{sint32}]{len, }
\item[{sint32}]{timeout\+Ms = {\ttfamily -\/1}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_tcp_socket_a35fb1c8b1f5235bce6418a75252c136e}


T\+C\+P socket接收数据 


\begin{DoxyParams}{参数}
{\em buf} & 接收缓存 \\
\hline
{\em len} & 缓存大小 \\
\hline
{\em timeout\+Ms} & 超时时间,-\/1\+:阻塞,0\+:立即返回,$>$0\+:超时时间ms \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回接收的数据长度,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


实现了 \hyperlink{class_socket}{Socket}.

\hypertarget{class_tcp_socket_a5f7504d2465e529139750cd36f794822}{\index{Tcp\+Socket@{Tcp\+Socket}!write\+Data@{write\+Data}}
\index{write\+Data@{write\+Data}!Tcp\+Socket@{Tcp\+Socket}}
\subsubsection[{write\+Data}]{\setlength{\rightskip}{0pt plus 5cm}sint32 Tcp\+Socket\+::write\+Data (
\begin{DoxyParamCaption}
\item[{const char $\ast$}]{buf, }
\item[{sint32}]{len, }
\item[{sint32}]{timeout\+Ms = {\ttfamily -\/1}}
\end{DoxyParamCaption}
)\hspace{0.3cm}{\ttfamily [virtual]}}}\label{class_tcp_socket_a5f7504d2465e529139750cd36f794822}


T\+C\+P socket发送数据 


\begin{DoxyParams}{参数}
{\em data} & 发送数据缓存 \\
\hline
{\em len} & 缓存大小 \\
\hline
{\em timeout\+Ms} & 超时时间,-\/1\+:阻塞,0\+:立即返回,$>$0\+:超时时间ms \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{返回}
成功返回发送的数据长度,失败返回\+S\+T\+A\+T\+U\+S\+\_\+\+E\+R\+R\+O\+R 
\end{DoxyReturn}
\begin{DoxyNote}{注解}
none 
\end{DoxyNote}


实现了 \hyperlink{class_socket}{Socket}.



该类的文档由以下文件生成\+:\begin{DoxyCompactItemize}
\item 
libemb/inc/\hyperlink{_socket_8h}{Socket.\+h}\item 
libemb/src/Socket.\+cpp\end{DoxyCompactItemize}
